Turn on more accessible mode
Skip Ribbon Commands
Skip to main content
Plantronics Spokes SDK

I recently had a chance to play around with the Spokes SDK from Plantronics. The Spokes SDK allows you to receive events from Plantronics headsets. The  events include notifications from buttons being pressed (call answer/end/mute/volume) as well as events if the user is wearing the headset.

Developer.plantronics.com has a number of good resources to get you started with Spokes, so I took the time to create an Add-In for the .net client to perform actions in CIC for the events coming from headset. For my purposes, I was testing with the DA45. Plantronics has a wide range of device types, but the DA45 is well suited for agents in a contact center. Using the sample code from their website, I was able to get a prototype up and running in almost no time at all, it might actually take me more time to write this blog than it did to write the code.

I was able to use the following events to perform actions in CIC.  

Action
Plantronics Event
CIC Action
USB Plugged In Device State Changed Log device information to trace log and pop toast
USB Unplugged Device State Changed Pop Toast
Headset Connected To DA45 Headset state change - In Range Set status to available.
Headset Unplugged from DA45 Headset state change - out of range Set status to Away From Desk
Mute/Volume Buttons Pressed Button Pressed None
Headset talk Button Pressed Button Pressed - HeadsetButton_Talk Answer alerting calls or disconnect the currently connected call.

Additionally, when the DA45 is connected, we will also trace out information to the log with product id, name, version and serial number.  

We want to be able to change the user’s status when the device is connected/disconnected. The .net client AddIn API doesn’t have methods to be able to change our status so we’ll need to get the IceLib session out of the service provider.

1
_session = (Session)serviceProvider.GetService(typeof(Session));

If you do not have the IceLib license on your CIC server, GetService will return null.

In Plantronics\PlantronicsManager.cs, Registration for events from Spokes is simple enough.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
public PlantronicsManager (IStatusManager statusManager, 
                            IInteractionManager interactionManager, 
                            INotificationService notificationService,
                            ITraceContext traceContext)
{
    _statusManager = statusManager;
    _interactionManager = interactionManager;
    _traceContext = traceContext;
    _notificationService = notificationService;
            
    m_sessionComManager = new SessionComManagerClass();
    m_sessionManagerEvents = m_sessionComManager as ISessionCOMManagerEvents_Event;
    m_comSession = m_sessionComManager.Register("Interaction Client Plantronics AddIn");

    // Now check if our plugin session was created
    if (m_comSession != null)
    {
        // detect devices added/removed
        m_sessionManagerEvents.DeviceStateChanged += OnDeviceStateChanged;

        //Get current Device
        m_device = m_comSession.ActiveDevice;

        // if we have a device register for events
        if (m_device != null)
        {
            // Register for device events
            RegisterEvents();
        }
    }
}

private void RegisterEvents()
{
    LogDeviceInfo(m_device);

    // Register for some device events
    m_deviceComEvents = m_device.DeviceEvents as IDeviceCOMEvents_Event;
    m_deviceComEvents.ButtonPressed += new IDeviceCOMEvents_ButtonPressedEventHandler(OnButtonPressed);

    m_deviceListenerEvents = m_device.DeviceListener as IDeviceListenerCOMEvents_Event;
    if (m_deviceListenerEvents != null)
    {
        m_deviceListenerEvents.HeadsetStateChanged += 
                      new IDeviceListenerCOMEvents_HeadsetStateChangedEventHandler(OnHeadsetStateChanged);
    }
}

We are using dependency injection to pass services into the PlantronicsManager.  Now when an event is raised from Spokes, we can call a method on the injected services to perform the action.  In this case, when the headset button is pressed, we will either pickup an alerting call, or disconnect a connected call. 

1
2
3
4
5
6
7
8
9
private void OnButtonPressed(object sender, _DeviceEventArgs e)
{
    Debug.WriteLine("OnButtonPressed " + e.ToString());
    _traceContext.Status("OnButtonPressed " + e.ToString());
    if (e.ButtonPressed == HeadsetButton.HeadsetButton_Talk)
    {
        _interactionManager.PickupOrDisconnectCall();
    }
}

Code for this prototype is available https://github.com/InteractiveIntelligence/Plantronics/tree/master/PlantronicsClientAddInA demo video is available on the youtube http://www.youtube.com/watch?v=pFQC-6TcQSo​

I encourage you to fork the code and use it in your own applications.

-Kevin

​​​​​​​​